<?
require("config.php");

$show_backnav = "product_menu";
$location_status .= "| Edit";

$menuname = array(
	"Info",
	"Pictures",
	"Color",
	"Size",
	"Specification",
	"Features",
	"Accessories",
	"Packaging",
);

$menutarget = array(
	"edit",
	"edit_pictures",
	"edit_color",
	"edit_size",
	"edit_specification",
	"edit_features",
	"edit_accessories",
	"edit_packaging",
);

$menutype = 2;

if (NULL!=$action){

	$dir = $table . "/";

	myUpload($Item01_pic,$Item01_pic_name,$dir);
	myUpload($Item02_pic,$Item02_pic_name,$dir);
	myUpload($Item03_pic,$Item03_pic_name,$dir);
	myUpload($Item04_pic,$Item04_pic_name,$dir);
	myUpload($Item05_pic,$Item05_pic_name,$dir);
	myUpload($Item06_pic,$Item06_pic_name,$dir);
	myUpload($Item07_pic,$Item07_pic_name,$dir);
	myUpload($Item08_pic,$Item08_pic_name,$dir);
	myUpload($Item09_pic,$Item09_pic_name,$dir);
	myUpload($Item10_pic,$Item10_pic_name,$dir);


	if ($Item01_pic_name == null) $Item01_pic_name = $bk_Item01_pic;
	if ($Item02_pic_name == null) $Item02_pic_name = $bk_Item02_pic;
	if ($Item03_pic_name == null) $Item03_pic_name = $bk_Item03_pic;
	if ($Item04_pic_name == null) $Item04_pic_name = $bk_Item04_pic;
	if ($Item05_pic_name == null) $Item05_pic_name = $bk_Item05_pic;
	if ($Item06_pic_name == null) $Item06_pic_name = $bk_Item06_pic;
	if ($Item07_pic_name == null) $Item07_pic_name = $bk_Item07_pic;
	if ($Item08_pic_name == null) $Item08_pic_name = $bk_Item08_pic;
	if ($Item09_pic_name == null) $Item09_pic_name = $bk_Item09_pic;
	if ($Item10_pic_name == null) $Item10_pic_name = $bk_Item10_pic;


	if ($remove_1=="ture") $Item01_pic_name=NULL;
	if ($remove_2=="ture") $Item02_pic_name=NULL;
	if ($remove_3=="ture") $Item03_pic_name=NULL;
	if ($remove_4=="ture") $Item04_pic_name=NULL;
	if ($remove_5=="ture") $Item05_pic_name=NULL;
	if ($remove_6=="ture") $Item06_pic_name=NULL;
	if ($remove_7=="ture") $Item07_pic_name=NULL;
	if ($remove_8=="ture") $Item08_pic_name=NULL;
	if ($remove_9=="ture") $Item09_pic_name=NULL;
	if ($remove_10=="ture") $Item10_pic_name=NULL;


for ($i=0;$i<count($sFeatures);$i++) {

	$sFeature .= "," . $sFeatures[$i];
}

	$sFeature = substr($sFeature,1);

   $field = array(
	    "special_features",
		"item01_features_text",
		"item02_features_text",
		"item03_features_text",
		"item04_features_text",
		"item05_features_text",
		"item06_features_text",
		"item07_features_text",
		"item08_features_text", 
		"item09_features_text",
		"item10_features_text",
		"item01_features_photo",
		"item02_features_photo",
		"item03_features_photo",
		"item04_features_photo",
		"item05_features_photo",
		"item06_features_photo",
		"item07_features_photo",
		"item08_features_photo", 
		"item09_features_photo",
		"item10_features_photo",
	);


   $content = array(
	    $sFeature,
		$Item01,
		$Item02,
		$Item03,
		$Item04,
		$Item05,
		$Item06,
		$Item07,
		$Item08,
		$Item09,
		$Item10,
		$Item01_pic_name,
		$Item02_pic_name,
		$Item03_pic_name,
		$Item04_pic_name,
		$Item05_pic_name,
		$Item06_pic_name,
		$Item07_pic_name,
		$Item08_pic_name,
		$Item09_pic_name,
	    $Item10_pic_name,
	);

   $expression = "id=$id";

   myUpdate($table,$field,$content,$expression);

   header("location:edit_info.php?id=$id&target=edit_accessories&a=5");

   exit();

}


if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");
  
}

$Query = "select 
item01_features_text,
item02_features_text,
item03_features_text,
item04_features_text,
item05_features_text,
item06_features_text,
item07_features_text,
item08_features_text, 
item09_features_text,
item10_features_text,
item01_features_photo,
item02_features_photo,
item03_features_photo,
item04_features_photo,
item05_features_photo,
item06_features_photo,
item07_features_photo,
item08_features_photo, 
item09_features_photo,
item10_features_photo,
special_features 
from pro_basic where id=$id Limit 1";
$r = myQuery($Query);

$Item01= $r[0][0];
$Item02= $r[0][1];
$Item03= $r[0][2];
$Item04= $r[0][3];
$Item05= $r[0][4];
$Item06= $r[0][5];
$Item07= $r[0][6];
$Item08= $r[0][7];
$Item09= $r[0][8];
$Item10= $r[0][9];
$Item01_pic= $r[0][10];
$Item02_pic= $r[0][11];
$Item03_pic= $r[0][12];
$Item04_pic= $r[0][13];
$Item05_pic= $r[0][14];
$Item06_pic= $r[0][15];
$Item07_pic= $r[0][16];
$Item08_pic= $r[0][17];
$Item09_pic= $r[0][18];
$Item10_pic= $r[0][19];
$Specail_Feature = $r[0][20];

$sFeature = split(",",$Specail_Feature);


//special features

$Query = "select 
code, name from pro_features";
$sp = myQuery($Query);

require($rela_path . "inc/header.php");

?>

<!--Content Start-->
<form action="" method="post" enctype="multipart/form-data" name="form1">

<!--hidden filed-->
<input name="action" type="hidden" value="edit">
<input name="id" type="hidden" value="<?print($id)?>">

<input name="bk_Item01_pic" type="hidden" value="<?print($Item01_pic)?>">
<input name="bk_Item02_pic" type="hidden" value="<?print($Item02_pic)?>">
<input name="bk_Item03_pic" type="hidden" value="<?print($Item03_pic)?>">
<input name="bk_Item04_pic" type="hidden" value="<?print($Item04_pic)?>">
<input name="bk_Item05_pic" type="hidden" value="<?print($Item05_pic)?>">
<input name="bk_Item06_pic" type="hidden" value="<?print($Item06_pic)?>">
<input name="bk_Item07_pic" type="hidden" value="<?print($Item07_pic)?>">
<input name="bk_Item08_pic" type="hidden" value="<?print($Item08_pic)?>">
<input name="bk_Item09_pic" type="hidden" value="<?print($Item09_pic)?>">
<input name="bk_Item10_pic" type="hidden" value="<?print($Item10_pic)?>">


                    <table width="95%" border="0" align="center">
                      <tr> 
                        
      <td align="right">
	  
	  <input type="image" src="../../images/bt_cancel.gif" width="78" height="23" onclick="Redirect('product_menu.php',1);return false;"> 
        <input type="image" src="../../images/bt_save.gif" width="76" height="22"> 



      </td>
                      </tr>
                    </table>
                    <table width="95%" border="0" align="center">
                      <tr> 
                        <td align="right">&nbsp; </td>
                      </tr>
                      <tr> 
                        
      <td><table border="0" cellspacing="0" cellpadding="2">
          <tr> 
            <td><b><u>features</u></b> :</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 01 </td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item01" size="60" value="<?print($Item01)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item01_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item01_pic,"remove_1")?>
			<input type="file" class="text" name="Item01_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 02</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item02" size="60" value="<?print($Item02)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item02_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item02_pic,"remove_2")?><input type="file" class="text" name="Item02_pic" size="60"> 

            </td>
          </tr>
          <tr> 
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 03</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item03" size="60" value="<?print($Item03)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item03_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item03_pic,"remove_3")?><input type="file" class="text" name="Item03_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 04</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item04" size="60" value="<?print($Item04)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item04_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item04_pic,"remove_4")?><input type="file" class="text" name="Item04_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 05</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item05" size="60" value="<?print($Item05)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item05_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item05_pic,"remove_5")?><input type="file" class="text" name="Item05_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 06</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item06" size="60" value="<?print($Item06)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item06_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item06_pic,"remove_6")?><input type="file" class="text" name="Item06_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 07</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item07" size="60" value="<?print($Item07)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item07_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item07_pic,"remove_7")?><input type="file" class="text" name="Item07_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 08</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item08" size="60" value="<?print($Item08)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item08_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item08_pic,"remove_8")?><input type="file" class="text" name="Item08_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 09</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item09" size="60" value="<?print($Item09)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item09_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item09_pic,"remove_9")?><input type="file" class="text" name="Item09_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Item 10 </td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td align="right">(Text)</td>
            <td> <input type="text" class="text" name="Item10" size="60" value="<?print($Item10)?>"> 
            </td>
          </tr>
          <tr> 
            <td align="right">(Photo)</td>
            <td><?loadImage($Item10_pic,$rela_path . $PIC_DIR . "$table/")?> 
			<?removeImage($Item10_pic,"remove_10")?><input type="file" class="text" name="Item10_pic" size="60"> 
            </td>
          </tr>
          <tr> 
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
		
		
		
		<table width="100%" border="0" cellspacing="1" cellpadding="0">
          <tr> 
            <td width="67%"><b><u>Special Features</u></b> :</td>
            <!--<td align="right" width="33%"><a href="#">Show Special Features List</a></td>-->
          </tr>
        </table>
        <br> 

<table width="100%" border="0" cellspacing="0" cellpadding="2">

<?
	for ($i=0;$i<count($sp);$i++) {
	
		$active = null;
		if (in_array($sp[$i][0],$sFeature)) $active="CHECKED";

	?>

          <tr> 
            <td> 
			<input type="checkbox" name="sFeatures[]" value="<?print($sp[$i][0])?>" <?print($active)?>> 
            <?print($sp[$i][1])?></td>
          </tr>

<?}?>
        </table>
        <p>&nbsp;</p></td>
                      </tr>
                    </table>



                    <table width="95%" border="0" align="center">
                      <tr> 
                        
      <td align="right">
	  
	  <input type="image" src="../../images/bt_cancel.gif" width="78" height="23" onclick="Redirect('product_menu.php',1);return false;"> 
        <input type="image" src="../../images/bt_save.gif" width="76" height="22"> 


      </td>
                      </tr>
                    </table>
                  </form>
            <!--Content End-->
            <?
require($rela_path . "inc/footer.php");
?>
        